package com.bzm.pojo.plugins.echarts;

import java.io.Serializable;
import java.util.List;

import lombok.Data;

@Data
public class EchartsCount implements Serializable{
	
	private static final long serialVersionUID = 8068993701639311512L;

	/**
	 * 数量
	 */
	private Integer counts;
	
	/**
	 * 时间
	 */
	private String dateStr;
	
	/**
	 * 类型
	 */
	private Integer type;

	
	private Integer sumCounts;
	
	public EchartsCount getToSumByDate(String daysStr, List<EchartsCount> countList,Integer toType) {
		EchartsCount newCount = new EchartsCount();
		newCount.setCounts(0);
		Integer sumCount = new Integer(0);
		if(countList.size()>0) {
			for (EchartsCount count : countList) {
				Integer ty = count.getType();
				if(toType==null) {
					if(daysStr.equals(count.getDateStr())) {
						sumCount += count.getCounts();
					}
				}else {
					if(toType.equals(ty)) {	
						if(daysStr.equals(count.getDateStr())) {
							sumCount += count.getCounts();
						}
					}
				}
			}
		}
		newCount.setSumCounts(sumCount);
		return newCount;
	}
}
